package org.dong.samples.util;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class NowTime {
	public final static String getTime() throws Exception {
		java.util.Date date = new java.util.Date();          // 获取一个Date对象
		Timestamp timeStamp = new Timestamp(date.getTime());     //   讲日期时间转换为数据库中的timestamp类型
		String d = timeStamp.toString();
		return d;
	}
	public final static Timestamp getTimeTimestamp() throws Exception {
		java.util.Date date = new java.util.Date();          // 获取一个Date对象
		Timestamp timeStamp = new Timestamp(date.getTime());     //   讲日期时间转换为数据库中的timestamp类型
		return timeStamp;
	}
	
	public final static Timestamp getStringTimestamp(String time) throws Exception {
		DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Timestamp timeStamp = new Timestamp(format.parse(time).getTime());     //   讲日期时间转换为数据库中的timestamp类型
		return timeStamp;
	}
}
